﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAO;
using WebComputers.Class;

namespace WebComputers
{
    public partial class site : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
            if (!IsPostBack)
            {
                Response.Cache.SetCacheability(HttpCacheability.NoCache);
                Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1));
                Response.Cache.SetNoStore();
                Response.AppendHeader("pragma", "no-cache");
                Response.Expires = 0;
                FillLoaiHangHoa();
            }
            FillCart();
        }

        private void FillLoaiHangHoa()
        {
            try
            {
                rptLoaiHoangHoa.DataSource = LoaiHangHoaDAO.SelectAll();
                rptLoaiHoangHoa.DataBind();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        protected void FillCart()
        {
            CartManager cart = new CartManager();
            lblSlg.InnerText = string.Format("{0:n0}", cart.TotalQuantity());
            lblTTien.InnerText = string.Format("{0:n0}", cart.TotalCost());
        }

        protected void rptLoaiHoangHoa_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            //if (e.Item.ItemIndex == 0)
            //{
            //    e.Item.FindControl("li-MenuLeft").Visible = false;
            //}
        }
    }
}